#!/usr/bin/env python
# -*- coding:UTF-8 -*-
"""
decorator.py
装饰模式代码原型
"""

class Component(object):
    def show(self): return self.__class__

class ComponentA(Component): pass
class ComponentB(Component): pass


class Decorator(Component):
    def __init__(self): self.component = None
    def decorate(self, component): self.component = component


class DecoratorA(Decorator):
    def show(self): return self.component.show(), self.__class__

class DecoratorB(Decorator):
    def show(self): return self.component.show(), self.__class__